#include<stdio.h>
#include<stdlib.h>

#define OK          1
#define INFEASIBLE -1
#define OVERFLOW   -2

typedef int  Status;
typedef int ElemType;
typedef struct LNode {
    ElemType data;
    struct LNode* next;
}LNode, * Linklist;

Status ReadList(Linklist L)
{
    Linklist p = L;
    ElemType e;
    while (scanf("%d", &e) != EOF && e >= 0)
    {
        Linklist pNew = (Linklist)malloc(sizeof(LNode));
        if (!pNew)
            exit(OVERFLOW);
        pNew->data = e;
        pNew->next = NULL;
        p->next = pNew;
        p = p->next;
    }
    return OK;
}

void PrintLastK(Linklist L, int k)
{
    Linklist p_Left = L;
    Linklist p = L;
    int i = 0;
    for (i = 0; i < k; i++)
    {
        p = p->next;
        if (!p)
            break;
    }
    if (!p)
        printf("NULL\n");
    else
    {
        while (p)
        {
            p = p->next;
            p_Left = p_Left->next;
        }
        printf("%d\n", p_Left->data);
    }
}

int main()
{
    Linklist L;
    L = (Linklist)malloc(sizeof(LNode));
    if (!L)
        exit(OVERFLOW);
    L->next = NULL;

    int k;
    scanf("%d", &k);
    ReadList(L);
    PrintLastK(L, k);
    return 0;
}